package site.kitcheng.springboottest.test;


import nl.basjes.parse.useragent.UserAgentAnalyzer;

/**
 * ClassName: UserAgent
 * Package: site.kitcheng.springboottest.test
 * Description:
 *
 * @Author jiangCheng
 * @Create 2025/3/21 15:40
 * @Version 1.0
 */
public class UserAgent {
    public static void main(String[] args) {
        // 创建 User-Agent 分析器


        // 示例 User-Agent
        String userAgentString = "User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.11 (KHTML, like Gecko) Ubuntu/11.10 Chromium/27.0.1453.93 Chrome/27.0.1453.93 Safari/537.36";

        UserAgentAnalyzer uaa = UserAgentAnalyzer
                .newBuilder()
            .hideMatcherLoadStats()
                .withCache(10000)
                .build();

        nl.basjes.parse.useragent.UserAgent.ImmutableUserAgent userAgent = uaa.parse(userAgentString);

        // 获取所有可用字段
        for (String field : userAgent.getAvailableFieldNamesSorted()) {
            System.out.println(field + ": " + userAgent.getValue(field));
        }


    }
}
